﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using ExamDemo.Models;

namespace ExamDemo.Data
{
    public class DbAdd:DropCreateDatabaseAlways<UsersContext>
    {
        protected override void Seed(UsersContext db)
        {
            db.Users.Add(new Models.Users
            {
                Username = "admin",
                Password = "123",
                CreatedAt = DateTime.Now,
                UpdatedAt = DateTime.Now,
                Version = 0
            });
            db.Messages.AddRange(new List<Messages>
            {
                new Messages
                {
                    FromUserId=1,
                    Content="考试",
                    CreatedAt=DateTime.Now,
                    UpdatedAt=DateTime.Now,
                    Version=0
                },
              
            });
            db.Comments.AddRange(new List<Comments>
            {
                new Comments
                {
                    FromUserId=1,
                    MsgId=1,
                    Content="考试",
                    CreatedAt=DateTime.Now,
                    UpdatedAt=DateTime.Now,
                    Version=0
                },
            });
            db.SaveChanges();
            base.Seed(db);

        }
    }
}